﻿package javacpp;   //切记不能修改包名(jin调用，包的路径在编译时已经固定)

import java.io.Console;

public class sdk extends Thread{
    static{
        System.loadLibrary("sdk");
    }
	@Override
    public void run() {
		//push audio stream to virtual sound-card，samplerate 48khz，mono 16 bit deep
        int myret = 0;
		int myport = 101;
		short[] mysample = new short[480];
		for(short i = 0;i<480;i++)
		{
			mysample[i] = i;
		}
		//return 0 correct，1 sound-card not exist
		myret = mysdk.sdkpushstream(myport, mysample);
	}
	public static void main(String[] args){
		Console console = System.console();
		if(console!=null)
		{
			console.printf("Console is available.");
		}
		sdk mysdk = new sdk();

		//system init
		String ret = mysdk.sdkcommand("init -node 6 -ip 192.168.0.110 -path C:/config/ -debug");
        console.printf(ret);

		//test play local file
		mysdk.sdkcommand("play -id 1 -s test.wav -d 1");

		//test the tts
		//mysdk.sdkcommand("tts -id 1 -r 1 -l 1 -d 1 -v 8 -s @$北猎广播语音合成测试@$");

		//test play local stream
		//mysdk.sdkcommand("live -id 1 -s 101 -d 1");

		while(true)
	    {
			System.out.printf("\n");
			System.out.printf(mysdk.sdknotify());
		}
    }
    public native String sdkcommand(String cmd);
    public native String sdknotify();
	public native int sdkpushstream(int port,short sample[]);  //sample count is 480,16bit short sample
}
